<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>购物车</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./index.css">
    <!-- 引入组件库 -->

    <script src="./vue.js"></script>
    <script src="./index.js"></script>
</head>

<body>
    <div id="app">
        <div id="content">
            <el-button type="success" @click="handleLoadTree" round>加载树形结构</el-button>
            <p>{{foo}}</p>>
            <el-tree 
            :data="data" 
            :props="defaultProps" 
            @node-click="handleNodeClick"
            show-checkbox
            @check-change="handleCheckChange"
            node-key="id"
            >
           </el-tree>
        </div>

    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                data: [],
                /** 树形数据end **/
                
                defaultProps: {
                    children: 'chirdren',
                    label: 'name'
                },
                foo:"get-element-by-id"
             
            },
            methods: {
                handleLoadTree() {
                    fetch("http://127.0.0.1:8080/api/getDate")
                    .then(res=>{
                        return res.json();
                    })
                    .then(res=>{
                         this.data=res.reult;
                    })
                    .catch(error=>{
                        console.log(error);
                    })
                    console.log("--------------->加载树形结构");

                },
                handleNodeClick(data){
                 
                },
                handleCheckChange(data, checked, indeterminate){
                        console.log(data+" "+checked+" "+indeterminate);
                },
                check(leafOnly){
                      console.log(leafOnly);
                }
            }



        });
    </script>

</body>

</html>